LicenseManager
@objc(LSLicenseManager)
final class LicenseManager : BaseManager
extension LicenseManager : CVarArg, CustomDebugStringConvertible, CustomStringConvertible, Equatable, Hashable, NSObjectProtocol
Entry point to the LicenseSpring SDK Use to obtain the license or common product information
-
Init LicenseManager with configuration
Throws
LSErrorif the configuration is invalid or the client cannot be initialized.Note
In Objective-C, pass an instance conforming to the
LSBaseStorageprotocol forbaseStorage. In Swift, pass an instance conforming toBaseStorage.Declaration
Swift
@objc init(configuration: Configuration, baseStorage: AnyObject? = nil) throwsParameters
configurationConfiguration of LicenseManager
baseStorageAn optional object used for low-level data storage operations such as reading, writing, and deleting raw license data. Accepts either a Swift implementation conforming to
BaseStorageor an Objective-C object conforming toLSBaseStorage. Ifnil, the default internal file-based storage is used. This parameter is primarily intended for advanced customization of how license files are persisted. -
Activated License or nil if no license is active.
Declaration
Swift
@objc var currentLicense: License? { get } -
Base Storage object passed by the user for custom license storage implementation
Declaration
Swift
let baseStorage: any BaseStorage -
Undocumented
Declaration
Swift
@objc func saveToFile() throws -
Activate the license using a license key asynchronously.
Declaration
Swift
@objc func activateLicense(licenseKey: String, completion: @escaping (License?, (any Error)?) -> Void) -
Activate the license using user and password.
Throws
Error if license activation fails. May be ofLSErrortype.Declaration
Swift
@objc func activateLicense(user: String, password: String) throws -> LicenseParameters
userUser ID, typically email in lowercase.
passwordUser’s password.
Return Value
Activated license.
-
Activate the license using user and password asynchronously.
Declaration
Swift
@objc func activateLicense(user: String, password: String, completion: @escaping (License?, (any Error)?) -> Void) -
Activate the license using serverId.
Throws
Error if license activation fails. May be ofLSErrortype.Declaration
Swift
@objc func activateLicense(user: String, password: String, serverId: Int64) throws -> LicenseParameters
userUser ID, typically email in lowercase.
passwordUser’s password.
Return Value
Activated license.
-
Activate the license using user, password, and server ID asynchronously.
Declaration
Swift
@objc func activateLicense(user: String, password: String, serverId: Int64, completion: @escaping (License?, (any Error)?) -> Void)Parameters
userUser ID, typically email in lowercase.
passwordUser’s password.
serverIdLicense ID, typically a 64-bit ID.
completion -
Activate the license using serverID.
Declaration
Swift
@objc(testGetActivateLicenseWithServerId:error:) func activateLicense(serverId: LicenseIDObjc) throws -> License -
Activate the license using license activation response file.
Throws
Error if license activation fails. May be ofLSErrortype.Declaration
Swift
@objc func activateLicenseOffline(_ activationResponseFile: URL) throws -> LicenseParameters
activationResponseFileActivation response file location.
Return Value
Activated license.
-
Activate the license using license activation response file asynchronously.
Declaration
Swift
@objc func activateLicenseOffline(_ activationResponseFile: URL, completion: @escaping (License?, (any Error)?) -> Void) -
Creates offline activation file request.
Throws
Error if create activation file fails. May be ofLSErrortype.Declaration
Swift
@objc func createOfflineActivationFile(licenseKey: String, preferredLocation: URL? = nil) throws -> URLParameters
licenseKeyLicense key to be activated offline.
preferredLocationOptional custom activation request file location. ‘~/Desktop/ls_activation.req’ by default.
Return Value
Location of offline activation file request.
-
Creates offline activation file request.
Throws
Error if create activation file fails. May be ofLSErrortype.Declaration
Swift
@objc func createOfflineActivationFile(user: String, password: String, preferredLocation: URL? = nil, serverID: Int64 = 0) throws -> URLParameters
userUser ID, typically email in lowercase.
passwordUser’s password.
preferredLocationOptional custom activation request file location. ‘~/Desktop/ls_activation.req’ by default.
serverIDserverID, server-side license identifier, typically 64-bit id.
Return Value
Location of offline activation file request.
-
Get Activation code for air gap activation.
Throws
Error if generation fails. May be ofLSErrortype.Declaration
Swift
@available(macOS, introduced: 10.15) @available(iOS, introduced: 13.0) @objc func generateAirGapActivationCode(initializationCode: String, licenseKey: String) throws -> StringParameters
initializationCodeCode received from the air gap activation portal.
licenseKeyLicense key of air gap license.
Return Value
Air gap Activation code. Empty string in case of error.
-
Verify Confirmation code for air gap activation.
Throws
Error if verification fails. May be ofLSErrortype.Declaration
Swift
@available(macOS, introduced: 10.15) @available(iOS, introduced: 13.0) @objc func verifyAirGapConfirmationCode(confirmationCode: String, licenseKey: String, policyID: Int) throwsParameters
confirmationCodeCode received from the air gap activation portal.
licenseKeyLicense key of air gap license.
policyIDPolicy id received from the air gap activation portal.
-
Activate air gap license using policy file.
Throws
Error if activation fails. May be ofLSErrortype.Declaration
Swift
@objc func activateLicense(airgapPolicyFile policyFile: URL, licenseKey: String, policyID: Int) throws -> LicenseParameters
licenseKeyLicense key.
policyIDId of the license policy.
Return Value
License if activation succeeded.
-
Activate air gap license using policy file asynchronously.
Declaration
Swift
@objc func activateLicense(airgapPolicyFile policyFile: URL, licenseKey: String, policyID: Int, completion: @escaping (License?, (any Error)?) -> Void) -
Retrieve URL for Single Sign-On license activation.
Throws
Error if request fails. May be ofLSErrortype.Declaration
Swift
@objc func requestSSOURL(useAuthCode: Bool = true, redirectURI: String = "") throws -> URLParameters
useAuthCodeIf
true(default), generates an SSO URL for the Authorization Code flow. Iffalse, uses the Implicit flow.redirectURIOptional redirect URI to use. Must be one of the allowed redirect URIs for the customer account. If empty or nil, the default (first) redirect URI is used.
Return Value
URL for Single Sign-On.
-
Retrieve URL for Single Sign-On license activation.
Throws
Error if request fails. May be ofLSErrortype.Declaration
Swift
@objc(requestSSOURLDetailedWithUseAuthCode:redirectURI:error:) func requestSSOURL(useAuthCode: Bool = true, redirectURI: String = "") throws -> SSOURLParameters
useAuthCodeIf
true(default), generates an SSO URL for the Authorization Code flow. Iffalse, uses the Implicit flow.redirectURIOptional redirect URI to use. Must be one of the allowed redirect URIs for the customer account. If empty or nil, the default (first) redirect URI is used.
Return Value
SSOURL for Single Sign-On.
-
Retrieve all available SSO URLs. The first element is the main SSO URL, followed by alternate URLs in the order received from the License API.
Throws
Error if request fails. May be ofLSErrortype.Declaration
Swift
@objc func getAllSSOUrls(useAuthCode: Bool = true, redirectURI: String = "") throws -> [URL]Parameters
useAuthCodeIf
true(default), generates SSO URLs for the Authorization Code flow. Iffalse, uses the Implicit flow.redirectURIOptional redirect URI to use. Must be one of the allowed redirect URIs for the customer account. If empty or nil, the default (first) redirect URI is used.
Return Value
Array of SSO URLs with the main URL first.
-
Activate the license using SSO token.
Throws
Error if license activation fails. May be ofLSErrortype.Declaration
Swift
@objc func activateLicense(ssoToken: String, redirectURI: String? = nil, useAuthCode: Bool = true) throws -> LicenseParameters
ssoTokenAuthorization code or ID token received from SSO login, depending on the flow.
redirectURIThe redirect URI that was used during the SSO login flow. Must match the redirect_uri from the SSO URL. Only used with Authorization Code flow. Pass
nilif using the default redirect URI.useAuthCodeIf
true(default), thessoTokenis treated as an authorization code. Iffalse, it is treated as an ID token (Implicit flow).Return Value
Activated license.
-
Activate the license using SSO token asynchronously.
Declaration
Swift
@objc func activateLicense(ssoToken: String, redirectURI: String? = nil, useAuthCode: Bool = true, completion: @escaping (License?, (any Error)?) -> Void)Parameters
ssoTokenAuthorization code or ID token received from SSO login, depending on the flow.
redirectURIThe redirect URI that was used during the SSO login flow. Must match the redirect_uri from the SSO URL. Only used with Authorization Code flow. Pass
nilif using the default redirect URI.useAuthCodeIf
true(default), thessoTokenis treated as an authorization code. Iffalse, it is treated as an ID token (Implicit flow).completion -
Request trial license from LicenseSpring platform.
Throws
Error if request fails. May be ofLSErrortype.Note
Combination of same hardwareID and product will ALWAYS give you the same trial key! This prevents people getting new trial keys on same computer.Declaration
Swift
@objc func requestTrialKey(with email: String?) throws -> StringReturn Value
Trial license key or user email in case of user-based product.
-
Request trial license from LicenseSpring platform.
Throws
Error if request fails. May be ofLSErrortype.Note
Combination of same hardwareID and product will ALWAYS give you the same trial key! This prevents people getting new trial keys on same computer.Declaration
Swift
@objc func requestTrialKey(for customer: Customer?, licensePolicy: String? = nil) throws -> StringParameters
licensePolicyLicense policy code. If nil, the default license policy for the product will be used.
Return Value
Trial license key or user email in case of user-based product.
-
Request trial license from LicenseSpring platform.
Note
Combination of same hardwareID and product will ALWAYS give you the same trial key! This prevents people getting new trial keys on same computer.Declaration
Swift
@objc func requestTrialKey(with email: String?, completion: @escaping (String?, (any Error)?) -> Void)Parameters
completionTrial license key or user email in case of user-based product if request succeeds, Error if request fails. May be of
LSErrortype. -
Request all available versions for the license user.
Throws
Error if request fails. May be ofLSErrortype.Declaration
Swift
@objc func requestAvailableVersions(licenseKey: String, env: String? = nil) throws -> [AvailableVersion]Parameters
licenseKeyLicense key.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
Return Value
An array of versions available for the license.
-
Request all available versions for the license user.
Declaration
Swift
@objc func requestAvailableVersions(licenseKey: String, env: String? = nil, completion: @escaping ([AvailableVersion]?, (any Error)?) -> Void)Parameters
licenseKeyLicense key.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
completionAn array of versions available for the license if request succeeds, Error if request fails. May be of
LSErrortype. -
Request all available versions for the license user.
Throws
Error if request fails. May be ofLSErrortype.Declaration
Swift
@objc func requestAvailableVersions(user: String, env: String? = nil) throws -> [AvailableVersion]Parameters
userLicense user name, usually email in lowercase.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
Return Value
An array of versions available for the license.
-
Request all available versions for the license user.
Declaration
Swift
@objc func requestAvailableVersions(user: String, env: String? = nil, completion: @escaping ([AvailableVersion]?, (any Error)?) -> Void)Parameters
userLicense user name, usually email in lowercase.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
completionAn array of versions available for the license if request succeeds, Error if request fails. May be of
LSErrortype. -
Request installation information for the license.
Throws
Error if request fails. May be ofLSErrortype.Declaration
Swift
@objc func requestInstallationFile(licenseKey: String, version: String? = nil, env: String? = nil) throws -> InstallationFileParameters
licenseKeyLicense key.
versionDesired product (app) version, optional. If not provided, the last available version assumed.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
Return Value
Installation information related to the license.
-
Request installation information for the license.
Declaration
Swift
@objc func requestInstallationFile(licenseKey: String, version: String? = nil, env: String? = nil, completion: @escaping (InstallationFile?, (any Error)?) -> Void)Parameters
licenseKeyLicense key.
versionDesired product (app) version, optional. If not provided, the last available version assumed.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
completionInstallation information related to the license if request succeeds, Error if request fails. May be of
LSErrortype. -
Request installation information for the license.
Throws
Error if request fails. May be ofLSErrortype.Declaration
Swift
@objc func requestInstallationFile(user: String, version: String? = nil, env: String? = nil) throws -> InstallationFileParameters
userLicense user name, usually email in lowercase.
versionDesired product (app) version, optional. If not provided, the last available version assumed.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
Return Value
Installation information related to the license.
-
Request installation information for the license.
Declaration
Swift
@objc func requestInstallationFile(user: String, version: String? = nil, env: String? = nil, completion: @escaping (InstallationFile?, (any Error)?) -> Void)Parameters
userLicense user name, usually email in lowercase.
versionDesired product (app) version, optional. If not provided, the last available version assumed.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
completionInstallation information related to the license if request succeeds, Error if request fails. May be of
LSErrortype. -
Request information about the product from LicenseSpring platform.
Throws
Error if request fails. May be ofLSErrortype.Note
In offline mode data will be retrieved from license file if present.Declaration
Swift
@objc func requestProductDetails(env: String? = nil) throws -> ProductDetailsParameters
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
Return Value
Product details.
-
Request information about the product from LicenseSpring platform.
Note
In offline mode data will be retrieved from license file if present.Declaration
Swift
@objc func requestProductDetails(env: String? = nil, completion: @escaping (ProductDetails?, (any Error)?) -> Void)Parameters
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
completionProduct details if request succeeds, Error if request fails. May be of
LSErrortype. -
Request all the license users on every order by some customer.
Throws
Error if request fails. May be of
LSErrortype.Note
More at /api/v4/customer_license_users
Declaration
Swift
@objc func requestLicenseUsers(for customerEmail: String) throws -> [User]Return Value
Array of the users related to the customer.
-
Request all the license users on every order by some customer.
Note
More at /api/v4/customer_license_users
Declaration
Swift
@objc func requestLicenseUsers(for customerEmail: String, completion: @escaping ([User]?, (any Error)?) -> Void)Parameters
completionArray of the users related to the customer if request succeeds, Error if request fails. May be of
LSErrortype. -
Change password for user based license.
Throws
Error if request fails. May be of
LSErrortype.Note
More at /api/v4/change_password
Declaration
Swift
@objc func changePassword(user: String, password: String, newPassword: String) throwsParameters
userUser email.
passwordCurrent user password.
newPasswordNew user password.
-
Change password for user based license.
Note
More at /api/v4/change_password
Declaration
Swift
@objc func changePassword(user: String, password: String, newPassword: String, completion: @escaping ((any Error)?) -> Void)Parameters
userUser email.
passwordCurrent user password.
newPasswordNew user password.
completionError if request fails. May be of
LSErrortype. -
Helper method to check connection to the LicenseSpring platform.
Declaration
Swift
@objc func checkConnection() -> BoolReturn Value
trueif SDK is able to connect to the LicenseSpring platform andfalseotherwise. -
Helper method to check connection to the LicenseSpring platform.
Declaration
Swift
@objc func checkConnection(completion: @escaping (Bool) -> Void)Parameters
completiontrueif SDK is able to connect to the LicenseSpring platform andfalseotherwise -
Remove license file and internal SDK files if any of them exist.
Note
Typically should be called after license deactivation in the app uninstaller.Throws
Error if clearing fails.Declaration
Swift
@objc func clearLocalStorage() throws -
Gets the users licences using user and password
Declaration
Swift
@objc func getUserLicenses(user: String, password: String) throws -> [UserLicensesData]Parameters
userUser ID, typically email in lowercase.
passwordUser’s password.
Return Value
Array of UserLicensesData
-
Gets the users licences using user and password
Declaration
Swift
@objc(getUserLicenseIDsWithUser:password:error:) func getUserLicenses(user: String, password: String) throws -> [LicenseIDObjc]Parameters
userUser ID, typically email in lowercase.
passwordUser’s password.
Return Value
Array of UserLicensesData
-
Gets the users licences using user and password
Declaration
Swift
@objc func getUserLicenses(user: String, password: String, completion: @escaping ([UserLicensesData]?, (any Error)?) -> Void)Parameters
userUser ID, typically email in lowercase.
passwordUser’s password.
completionArray of UserLicensesData, Error if request fails. May be of
LSErrortype. -
Gets the user’s licenses using SSO token.
Declaration
Swift
@objc func getUserLicenses(ssoToken: String, redirectURI: String? = nil, useAuthCode: Bool = true) throws -> [UserLicensesData]Parameters
ssoTokenAuthorization code or ID token received from SSO user authorization, depending on the flow.
redirectURIOptional redirect URI that must match the one used during SSO login. Only used with Authorization Code flow.
useAuthCodeIf
true(default), thessoTokenis treated as an authorization code. Iffalse, it is treated as an ID token (Implicit flow).Return Value
Array of UserLicensesData
-
Version of LicenseSpring SDK
Declaration
Swift
@objc static let sdkVersion: String -
Version of LicenseSpring API
Declaration
Swift
@objc static let apiVersion: Int -
Version of FloatingServerV2 API
Declaration
Swift
@objc static let fsV2ApiVersion: Int -
reconfigure(appName:appVersion: customerAccountCode: airgapKey: serviceURL: hardwareID: collectHostNameAndLocalIP: networkTimeout: proxyHost: proxyPort: gracePeriod: skipResponseSignatureChecks: client_id: client_secret: CryptoProviderKey: isOauth: extendedOptions: ) Undocumented
Declaration
Swift
func reconfigure(appName: String? = nil, appVersion: String? = nil, customerAccountCode: String? = nil, airgapKey: String? = nil, serviceURL: URL? = nil, hardwareID: String? = nil, collectHostNameAndLocalIP: Bool? = nil, networkTimeout: TimeInterval? = nil, proxyHost: String? = nil, proxyPort: UInt16? = nil, gracePeriod: TimeInterval? = nil, skipResponseSignatureChecks: Bool? = nil, client_id: String? = nil, client_secret: String? = nil, CryptoProviderKey: String? = nil, isOauth: Bool? = nil, extendedOptions: ExtendedOptions? = nil) throws -
Extract SSO license token from URL.
Throws
Error ifurlStringhas invalid format or scheme mismatched.Declaration
Swift
@objc static func extractSSOToken(from urlString: String, scheme: String, useAuthCode: Bool = true) throws -> StringParameters
schemeExpected URL scheme to ensure URL is valid. If scheme mismatched, the error is thrown.
useAuthCodeIf
true(default), extracts thecodequery parameter (Authorization Code flow). Iffalse, extracts theid_tokenfragment (Implicit flow).Return Value
SSO token to activate the license.